<template>
	<view class="mainpadding2">
		<view class="ffffff mainpadding_top flexbetween radius">
			<view class="titletext hei_text bold">原密码</view>
			<input type="text"placeholder="请输入" style="text-align: right;" class="hei_text main_size bold" v-model="oldpassword">
		</view>
		<view class="ffffff mainpadding_top flexbetween radius">
			<view class="titletext hei_text bold">新密码</view>
			<input type="text"placeholder="请输入" style="text-align: right;" class="hei_text main_size bold" v-model="newpassword">
		</view>
		<view class="ffffff mainpadding_top flexbetween radius">
			<view class="titletext hei_text bold">确认新密码</view>
			<input type="text"placeholder="请输入" style="text-align: right;" class="hei_text main_size bold" v-model="renewpassword">
		</view>
		<view class="posibottom mainpadding" style="bottom: 0;">
			<view class="submitbtn" @click="submit">确认修改</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				oldpassword:"",
				newpassword:"",
				renewpassword:"",
			}
		},
		methods: {
			submit(){
				if(this.oldpassword==""){
					httpRequest.toast("请输入原密码！")
					return false
				}
				if(this.newpassword==""){
					httpRequest.toast("请输入新密码！")
					return false
				}
				if(this.renewpassword==""){
					httpRequest.toast("请确认新密码！")
					return false
				}
				httpRequest.request('/api/user/changepwd', 'POST', {
					oldpassword:this.oldpassword,
					newpassword:this.newpassword,
					renewpassword:this.renewpassword
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg);
					if(res.code==1){
						uni.clearStorageSync()
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
		}
	}
</script>

<style>

</style>
